<?php
namespace app\http\middleware;

use think\Response;

class User
{
    public function handle($request, \Closure $next)
    {
        $user = Db('user')->where('token',$request->token)->field('token',true)->find();
        if(!$user){
            return Response::create(['data' => '', 'code' => 1, 'msg' => '登录失效'],'json');
        }
        $request->user = $user;
        return $next($request);
    }
}